<%@page contentType="text/html;charset=utf-8" pageEncoding="UTF-8" %>
<%@page import="org.ipo.mm.web.util.ConstantManager, java.util.Collection, org.ipo.mm.web.util.security.SecurityManager" %>
<%@taglib prefix="h" uri="http://struts.apache.org/tags-html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="l" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="b" uri="http://struts.apache.org/tags-bean" %>
<h1><b:message key="cities_create"/><div id="detailTitle"> </div></h1>
<div id="cityForm">
<fieldset>
<div>
     <h:form styleId="addCityForm" styleClass="form" action="/protected/city?method=${param['method']}" enctype="multipart/form-data; charset=utf-8">
        <table border="0">
                <tr>
                <td><span class="important"><b:message key="cities_region"/></span></td>
                <td>
                    <h:select property="region" styleId="regionId" styleClass="editable required">
                        <h:option value="">
                            <b:message key="inst_choose_region"/>
                        </h:option>
                <l:present name="dispatch.CityForm.regions" scope = "request">
                <l:iterate id="regions" name="dispatch.CityForm.regions" scope="request">
                            <h:option value="${regions.id}">
                                <b:write name="regions" property="name"/>
                            </h:option>
                        </l:iterate>                     
                        
                </l:present>

                    </h:select>
                 <h:submit property="operation" styleClass="hideInDialog" onclick="$('#addCityForm').validate().cancelSubmit = true;"><b:message key="regions_create"/></h:submit>
				 
                    <span class="error" ><h:errors property="region" /></span>
                </td>

 
            <tr>
                <td><span class="important"><b:message key="cities_name"/></span></td>
                <td><h:text styleClass="editable required" property="name" size="100" maxlength="512" styleId="name"/><span class="error" ><h:errors property="name" /></span></td>
            </tr>
            <tr>
                <td><b:message key="cities_zip"/></td>
                <td><h:text styleClass="editable" styleId="zipCode" property="zipCode"/></td>
            </tr>
            <tr>
                <td><b:message key="gen_note"/></td>
                <td><h:textarea styleClass="editable" property="note" styleId="note" cols="100" rows="10"/></td>
            </tr>

        </table>
        <c:if test="${param['method'] == 'showCreateCityForm'}">
            <h:submit property="submit"><b:message key="gen_create"/></h:submit>
        </c:if>

        <c:if test="${param['method'] == 'showUpdateCityForm'}">
            <h:submit property="submit" ><b:message key="gen_update"/></h:submit>
        </c:if>
<!--        <h:cancel onclick="$('#createNewCity').dialog('close');return false;"><b:message key="gen_cancel"/></h:cancel>-->
    	<input type="reset" value="<b:message key="gen_cancel"/>" onclick="cancelForm();"/>

     </h:form>
</div>
</fieldset>
</div>

<script type="text/javascript">
function cancelForm(){
		history.go(-1);
}
</script>